<?php

function _bar(){

$html_bar = <<<HTML
<div class="bar">
    %s
</div>
HTML;

$html_main = <<<HTML
	<a class="bar-left" href="main.php">Trang Chủ</a>
HTML;

$html_admin = <<<HTML
	<a class="bar-left" href="admin.php">Quản lý</a>
HTML;

$html_login_register = <<<HTML
	<a id="login" class="bar-right" href="javascript:dialog('login')">Đăng nhập</a>
    <a id="register" class="bar-right" href="javascript:dialog('register')">Đăng ký</a>
HTML;

$html_hello_logout = <<<HTML
	<a class="bar-right" href="action.php?do=logout">Thoát</a>
	<a class="bar-right">Chào %s</a>
HTML;

$inner_html = '';

$inner_html .= $html_main;
if (check_permission('admin')){ $inner_html .= $html_admin; }
if (check_permission('user')){ 
	$inner_html .= sprintf($html_hello_logout,$_SESSION['username']);
} else {
	$inner_html .= $html_login_register;
}

printf($html_bar,$inner_html);
}

_bar();

?>